According to an image compressing method known as one of general image compressing techniques, an image is divided into specific blocks, representative colors are extracted from each block, and the color of each pixel in a block is replaced with one of the extracted representative colors.
Usually, in such an image compressing method, the number of extracted representative colors is fixed. Accordingly, in the case where the number of colors used in a block is larger than the number of predetermined representative colors, a color not applicable to any one of the representative colors is replaced with one of the representative colors (that is, the reduction of the number of colors occurs). As a result, image quality may deteriorate. Meanwhile, even in the case where image quality is not likely to deteriorate by compression based on the small number of representative colors, such as in the case where the number of colors contained in an image before compression is small, and in the case where an image is extremely monotonous, compression processing is performed by extracting the preset fixed number of representative colors. Accordingly, since the representative colors are extracted more than the necessary number, the data size after the compression processing becomes larger unnecessarily. As a result, high compression ratio is hardly attained.
With regard to the above problems, Japanese Unexamined Patent Publication (JP-A) No. 2011-193394 discloses the following technique. In an image processing apparatus configured to perform compression and extension for image data including color data for each dot, the number of colors of a dot group in a prescribed region is detected. Then, when the detected number of colors is a first number, the image data of the dot group in the prescribed region are subjected to compression and extension in a reversible compression manner. On the other hand, when the detected number of colors is a second number larger than the first number, the image data of the dot group in the prescribed region are subjected to compression and extension in a nonreversible compression manner.
As a technique to attain high compression ratio while suppressing image quality deterioration, it may be considered to perform compression processing again by increasing or decreasing the number of representative colors. However, the propriety of the number of representative colors cannot be judged unless compression processing is actually performed. Accordingly, the production of compression data takes much time. Further, the original image data are needed to be retained until the compression processing is completed. As a result, the original image data are obliged to occupy a memory.
Further, as another technique, it may be considered to evaluate an image of a compression target so as to determine the number of representative colors and to perform compression based on the determined number of representative colors. However, according to this technique, during the evaluation of the image of the compression target, the compression processing cannot be started. Accordingly, also, the production of compression data takes much time. Further, separately from the compression processing, processing to evaluate an image is needed to be added newly, which results in that the processing becomes complicate.
Furthermore, according to the technique of the above JP-A No. 2011-193394, when the number of colors of a divided block is equal to or larger than the predetermined number, the block is subjected to pseudo gradation. Meanwhile, when the number of colors of a block is less than the predetermined number, the block is made as it is. Then, compression is performed by recording a color arrangement and color information of each block, whereby it may be possible to suppress extraction of representative colors more than necessary. However, in this technique, color information data of at least the preset predetermined number are needed to be retained for the compression data of one block. Accordingly, if the predetermined number is larger than necessary, high compression ratio is hardly attained. Further, if compression processing has been once performed based on the predetermined number, it may be not possible to perform processing to further recompress the compression data by reducing the predetermined number later. Therefore, even in the case where image quality deterioration due to further compression is not acknowledged, the compression is hardly performed more than that. As a result, high compression ratio cannot be attained. The present invention seeks to solve the problem.